<?php
require_once './data/users_dangnhap.php';
?>
<from method ="POST">

    <link rel="slintylesheet" type="text/css" href="./public/css/style.css">

    <p><div class="page-form">
        <div class="login-form">
            <h1 class="header-form">Login</h1>
            <div class="header-form-description">Don't use Virb yet? Take the tour or join now</div>
            <p><form id="login"  method="post">
                <p> UserName   <input name="username" type="text">

                <p> Password  <input name="password" type="password">
                    <a href="">Forgot your password?</a><a href="">Register</a>
                <p><input id="submit"   name="submit"   type="submit" value="Log in">

            </form>
        </div>
    </div>
    <?php
    if (isset($_POST['submit']))
        :
        ?>
        <?php
        $username = $_POST['username'];
        $password = $_POST['password'];
        $isOk = FALSE;
        $index = -1;
        for ($i = 0; $i < count($users); $i++) {
            if ((strcmp($users[$i]['username'], $username) == 0) &&
                    (strcmp($users[$i]['password'], $password) == 0)) {
                $isOk = TRUE;
                $index = $i;
            }
        }
        if ($isOk) {
            //Đăng nhập thành công
            header("Location: http://localhost:82/nxb-web1/flims.php?uid=" . $users[$index]['id']);
        } else {
            echo 'Đăng nhập thất bại';
        }
        ?>
<?php endif; ?>